package com.gin.pixiv.response.user

import com.gin.pixiv.response.field.Thumbnails


/**
 * 根据用户推荐的作品或其他用户
 */
class UserRecommendBody {
    var thumbnails: Thumbnails? = null
    var recommendUsers: List<RecommendUser>? = null
    var users: List<UserInfo>? = null

    companion object {
        class RecommendUser {
            var userId: Long? = null
            var illustIds: List<Long>? = null
            var novelIds: List<Long>? = null
        }
    }

    /**
     * 合并用户信息和作品信息
     */
    fun getMergedList(): List<UserRecommendInfoBody> {
        if (users == null || users!!.isEmpty()) {
            return ArrayList()
        }
        return users!!.stream().map {
            val illust = thumbnails!!.illust!!.filter { item -> item.userId == it.userId }
            val novel = thumbnails!!.novel!!.filter { item -> item.userId == it.userId }
            UserRecommendInfoBody(it, illust, novel)
        }.toList()
    }
}
